// https://www.zhipin.com //爬取boss直聘上的信息
let https = require("https");
//cheerio 作用类似jQuery  可以对文档对象进行查询
let cheerio = require("cheerio");
//爬取的网址
let url = "https://www.zhipin.com/chengdu/";
//过滤页面的
function filterPage(html){
    //获取左边菜单栏项
    let $ = cheerio.load(html);
    let menus = $('.job-menu');
    menus.each((idnex,element)=>{
        let menuTitle = $(element).find("dl").find("dd").find("b").text();
        let menuList = $(element).find("dl").find("dd").find("a");
        console.log(menuTitle+" ");
        menuList.each((index,value)=>{
            console.log($(value).text());
        })
    })
   //console.log(menuTitle)
}
//页面的内容
let html = "";
https.get(url,(res)=>{
    res.on("data",function(data){
        //console.log(data); 
        html+=data;
    })
    res.on("error",function(){
        //console.log(err);
    })
    res.on("end",function(){
        //console.log(html)
        filterPage(html);
        console.log("网页已经处理完毕")
    })
})